<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>回款管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initOrgTree();
        initAuthOrgTree();
        initGrid();//grid
        initTotalApl();
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
            getInitTotalApl(data);
        });

    });

    function initTotalApl(){
        $("#totalApl").text("合计回款记录数:${totalApl}笔");
        var totalRecoveryAmt = FormatMoney(${totalRecoveryAmt/100});
        $("#totalRecoveryAmt").text("合计回款金额:"+totalRecoveryAmt + "元");
    }

    function  getInitTotalApl(data){
        $.ajax({
            type: 'get',
            dataType:'json',
            /*data:{Param:JSON.stringify(data)},*/
            data:data,
            url: '<%=path%>/clt/auth/rebate/getInitTotalApl.do',
            success:function(successData){
                var totalApl = successData.totalApl;
                $("#totalApl").text("合计回款记录数:"+ totalApl +"笔");
                var totalRecoveryAmt = FormatMoney(successData.totalRecoveryAmt/100);
                $("#totalRecoveryAmt").text("合计回款金额:"+totalRecoveryAmt + "元");
            }
        });
    }

    function clearBtn() {
        $("#searchBar").ligerForm();
        var cstMgrOrgCd = liger.get("cstMgrOrgCd");
        cstMgrOrgCd.selectValue(" ");
        var authOrgCd = liger.get("authOrgCd");
        authOrgCd.selectValue(" ");
        var form = new liger.get("searchBar");
        form.setData({
            paySchNo : " ",
            cstNm: " ",
            cstMgrOrgCd:"0000",
            aplCrtTmStart :"",
            aplCrtTmEnd:" ",
            lsCntNo:" ",
            authOrgCd:"0000"
        });
    }

    //初始化列表
    function initGrid() {
        var params = {};
        $("#grid").ligerGrid({
            url: '<%=path%>/clt/auth/rebate/initList.do',
            method: 'get',
            parms: params,
            columns: [
                {display: '事业部', name: 'buOrgNm', minWidth: 60, align: 'center', enabledSort: true},
                {display: '省公司', name: 'cstMgrOrgNm', minWidth: 100, align: 'center', enabledSort: true},
                {display: '承租人', name: 'cstNm', minWidth: 80, align: 'center', enabledSort: true},
                {display: '支付表号', name: 'paySchNo', minWidth: 80, align: 'center', enabledSort: true},
                {display: '逾期天数', name: 'overdueDay', minWidth: 80, align: 'center', enabledSort: true},
                {display: '委案时间', name: 'auCrtTm', minWidth: 80, align: 'center', enabledSort: true,render: renderDate},
                {display: '委案金额', name: 'authAmt', minWidth: 80, align: 'center', enabledSort: true,
                    render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.authAmt/100);
                    }
                },
                {display: '回款申请日期', name: 'crtTm', minWidth: 80, align: 'center', enabledSort: true,render: renderDate},
                {display: '打款日期', name: 'payDt', minWidth: 80, align: 'center', enabledSort: true,render: renderDate},
                {display: '回款金额', name: 'recoveryAmt', minWidth: 80, align: 'center', enabledSort: true,
                    render:function(rowdata,index,value){
                        return '&yen;'+FormatMoney(rowdata.recoveryAmt/100);
                    }
                },
                {display: '委案机构', name: 'authOrgNm', minWidth: 80, align: 'center', enabledSort: true}

            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers: true,
            enabledEdit: true,
            usePagerOnLessPagesize: true,
        });
        grid = liger.get("grid");
        grid.setHeight(500);

    }

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        var h = "￥" + FormatMoney(value);
        return h;
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    //初始化组织架构树
    var searchOrgTree = null;
    function initOrgTree(){
        var params = {};
        <%--params.cstMgrOrgCd = '${currOrg}';--%>
        searchOrgTree = $("#cstMgrOrgCd").ligerComboBox({
            width: 480,
            selectBoxWidth: 480,
            selectBoxHeight: 150,
            //限制只能选叶节点，父节点不能点击
            treeLeafOnly: false,
            valueField: 'orgCd',
            textField: 'orgDispNm',
            showTreePath: true,
            tree: {
                ajaxType: 'get',
                idFieldName:'orgCd',
                textFieldName: 'orgDispNm',
                checkbox: false,
                parentIcon: "none",
                childIcon: "none",
                needCancel : false,
                isExpand: 2
            }
        });
        $.ajax({
            type: 'get',
            dataType:'json',
            data: params,
            url: '<%=path%>/project/prjbscinfo/searchBuOrgTree.do',
            success:function(msg){
                if(msg.success == 1){
                    searchOrgTree.treeManager.setData(msg.data);
                    searchOrgTree.clear();
                    searchOrgTree.setValue('0000');
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }

    //初始化委案机构组织架构树
    var searchAuthOrgTree = null;
    function initAuthOrgTree(){
        var params = {};
        searchAuthOrgTree = $("#authOrgCd").ligerComboBox({
            width: 480,
            selectBoxWidth: 480,
            selectBoxHeight: 150,
            //限制只能选叶节点，父节点不能点击
            treeLeafOnly: false,
            valueField: 'orgCd',
            textField: 'orgDispNm',
            showTreePath: true,
            tree: {
                ajaxType: 'get',
                idFieldName:'orgCd',
                textFieldName: 'orgDispNm',
                checkbox: false,
                parentIcon: "none",
                childIcon: "none",
                needCancel : false,
                isExpand: 2
            }
        });
        $.ajax({
            type: 'get',
            dataType:'json',
            data: params,
            url: '<%=path%>/project/prjbscinfo/searchBuOrgTree.do',
            success:function(msg){
                if(msg.success == 1){
                    searchAuthOrgTree.treeManager.setData(msg.data);
                    searchAuthOrgTree.clear();
                    searchAuthOrgTree.setValue('0000');
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }

</script>

<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div class="searchArea">
            <form id="searchBar">
                <div class="fieldset1 clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">支付表号</div>
                        <div class="field">
                            <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">承租人</div>
                        <div class="field">
                            <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox" id="">
                        <div class="label">所属组织架构</div>
                        <div class="field">
                            <input name="cstMgrOrgCd" id="cstMgrOrgCd" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">回款申请日期</div>
                        <div class="field">
                            <input ligerui="width: 82" name="aplCrtTmStart" id="aplCrtTmStart" type="text" class="ui-datepicker"
                                   value="">
                            -
                            <input ligerui="width: 82" name="aplCrtTmEnd" id="aplCrtTmEnd" type="text" class="ui-datepicker"
                                   value="">
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">合同号</div>
                        <div class="field">
                            <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">委案机构</div>
                        <div class="field">
                            <input name="authOrgCd" id="authOrgCd" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="clearFix"></div>
                    <div class="btnsBox">
                        <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                        <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                    </div>
                </div>
            </form>
        </div>
            <div class="fieldBox col_33">
                <div class="label">
                    <span id="totalApl" style="color: red;"></span>
                        &nbsp;&nbsp;&nbsp;
                    <span id="totalRecoveryAmt" style="color: red;"></span>
                </div>
            </div>
        <div id="grid" class="sq-grid"></div>

</div>
</div>
</body>
</html>